package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.ProductSkuVo;
import com.spzx.product.api.domain.SkuLockVo;
import com.spzx.product.api.domain.SkuPriceVo;
import com.spzx.product.api.factory.RemoteProductFallbackFactory;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = ServiceNameConstants.PRODUCT_SERVICE,
        fallbackFactory = RemoteProductFallbackFactory.class)
public interface RemoteProductService {

    @GetMapping("/productSku/getProductSku/{skuId}")
    R<ProductSkuVo> getProductSku(
            @Parameter(description = "skuId")
            @PathVariable("skuId") Long skuId,
            @Parameter(description =  "请求来源，用于标识发起请求的客户端或系统")
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    @GetMapping("/productSku/getSkuPrice/{skuId}")
    R<SkuPriceVo> getSkuPrice(
            @Parameter(description = "商品skuId")
            @PathVariable("skuId") Long skuId,
            @Parameter(description =  "请求来源，用于标识发起请求的客户端或系统")
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    @PostMapping(value = "/productSku/getSkuPriceList")
    R<List<SkuPriceVo>> getSkuPriceList(
            @Parameter(description = "商品skuId列表")
            @RequestBody List<Long> skuIdList,
            @Parameter(description =  "请求来源，用于标识发起请求的客户端或系统")
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    @PostMapping("/skuStock/checkAndLock/{orderNo}")
    R<String> checkAndLock(
            @Parameter(description = "订单号")
            @PathVariable("orderNo") String orderNo,
            @Parameter(description = "商品sku库存列表")
            @RequestBody List<SkuLockVo> skuLockVoList,
            @Parameter(description =  "请求来源，用于标识发起请求的客户端或系统")
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
